Skip to content

Conversation

@zwpaper
Copy link
Contributor

@zwpaper zwpaper commented Sep 9, 2025

when sending a invalid range header to serveStatic, you may get the following error:

 {
  error: 'The value of "start" is out of range. It must be an integer. Received NaN',
  stack: 'RangeError [ERR_OUT_OF_RANGE]: The value of "start" is out of range. It must be an integer. Received NaN\n' +
    '    at new ReadStream (node:internal/fs/streams:207:5)\n' +
    '    at createReadStream (node:fs:3159:10)\n' +
    '    at <anonymous> (/app/node_modules/@hono/node-server/dist/serve-static.mjs:115:20)\n' +
  method: 'GET',
  path: '/static',
  userAgent: 'curl/8.7.1'
}

for example, i send the following request to get a static file:

curl -H 'range: hello' http://example.com/static

This PR improves the handling of the parseInt function by defaulting to 0 whenever error occurred.

Copy link
Member

@yusukebe yusukebe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@yusukebe
Copy link
Member

Hi @zwpaper

Thank you for the PR. I added the test and fixed the logic myself. Looks good. Merging.

@yusukebe yusukebe merged commit fc9f9ab into honojs:main Sep 10, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants